#include <stdio.h>
int binary_search(int a[], int n, int key)
{
	int left = 0, right = n - 1, mid;
	while (left <= right) {
		mid = (left + right) / 2;
		if (a[mid] > n) {
			right = mid + 1;
		}
		else if (a [mid]< n) {
			left = mid + 1;
		}
		else {
			return mid;
		}
	}
	return -1;
}